open(FH,"</home/uec-00/yapingli/code/performance_test/k-allele/normal_snp_summary.txt") or die;
my @in=<FH>;
chomp(@in);
close(FH);
my @out;
my %in_hash = ();
foreach my $line(@in){
	my @splitin=split "\t",$line;
	my $key=$splitin[1]."~".$splitin[2]."~".$splitin[3]."~".$splitin[4];
	my $value=$splitin[8]."~".$splitin[9];
	$in_hash{$key} = $value;
}

my @min_map_qs=(1,5,10,15,20,25,30);
my @min_base_qs=(1,5,10,15,20,25,30);
my @min_read_covs=(1..20);
my @min_allele_counts=(1..5);
foreach my $min_map_q(@min_map_qs){
	foreach my $min_base_q(@min_base_qs){
		foreach my $min_read_cov(@min_read_covs){
			my @fp_values;
			my %temp_hash = ();
			foreach my $min_allele_count(@min_allele_counts){
				my $key=$min_map_q."~".$min_base_q."~".$min_read_cov."~".$min_allele_count;
				my $value=$in_hash{$key};
				my @temp=split "~",$value;
				my $fp = $temp[0];
				push(@fp_values,$fp);
				my $temp_key=$fp;
				$temp_hash{$fp} = @temp;
			}
			@fp_values=sort(@fp_values);
			my $auc=0;
			for(my $i=0;$i<$#fp_values-1;$i++){
				my @fp_fn_1=$temp_hash{$fp_values[$i]};
				my @fp_fn_2=$temp_hash{$fp_values[$i+1]};
				$auc+=0.5*($fp_fn_2[0]-$fp_fn_1[0])*(2-$fp_fn_2[1]-$fp_fn_1[1]);
			}
			push(@out,"$min_map_q\t$min_base_q\t$min_read_cov\t$auc\n");
		}
	}
}
open(OUT,">/home/uec-00/yapingli/code/performance_test/auc_summary.txt");
print OUT @out;
close(OUT);

	